require(readxl)
source('data.clean.R')
data.prep <- function(){
# load data
X2020_01_20_MASTER_dataset <- read_excel("2020-01-20 MASTER dataset.xlsx",col_names = TRUE, skip = 2)
antidep <- as.data.frame(X2020_01_20_MASTER_dataset)
# include only the needed columns
includedColumns <- c('Study_No','Study_year','Drug','Responders...56','No_randomised','Dose_delivered_mean', # 'Responders',
'Overall_study_RoB','Dose_range','Age_mean')
antidep <- antidep[,includedColumns]
# change column names
names(antidep) <- c('studyid','study_year','drug','r','n','dose','ROB','dose_range','age')
# after 522 we have empty cells in the excel file
antidep <- antidep[antidep$studyid%in%1:522,]
# change variables class
antidep$study_year <- as.numeric(antidep$study_year)
antidep$drug <- as.factor(antidep$drug)
antidep$r <- round(as.numeric(antidep$r))
antidep$n <- as.numeric(antidep$n)
antidep$dose <- as.numeric(antidep$dose)
antidep$ROB <- as.factor(antidep$ROB)
antidep$dose_range <- as.factor(antidep$dose_range)
antidep$age <- as.numeric(antidep$age)
# clean rows with NA's in r, n and dose & studies that report the same dose
antidep <- removeNAdosresdata.fun(antidep)$dataset
antidep <- antidep[antidep$exclude==FALSE,]
# exclude single-arm trials
antidep <- exludesinglearmsdata.fun(antidep,studyid = studyid)
# order doses within each study - start from 0
antidep_to_order <- sapply(unique(antidep$studyid), function(i) antidep[antidep$studyid==i,][order(antidep$dose[antidep$studyid==i]),],simplify = FALSE)
antidep <- do.call(rbind, antidep_to_order)
return(antidep)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.